import 'package:flutter_demo1/http/core/hi_net.dart';
import 'package:flutter_demo1/http/request/base_request.dart';
import 'package:flutter_demo1/http/request/home_request.dart';
import 'package:flutter_demo1/model/home_mo.dart';

class HomeDao {
  static get(String categoryName, {int pageIndex = 1, int pageSize = 1}) async {
    BaseRequest request = HomeRequest();
    request.pathParams = categoryName;
    request.add("pageIndex", pageIndex).add("pageSize", pageSize);
    var result = await HiNet.getInstance().fire(request);
    print("result::$result");

    result["data"] = {
      "bannerList": [
        {
          "id": "59",
          "sticky": 1,
          "type": "recommend",
          "title": "好课推荐",
          "subtitle": "AI赋能与智能化工具实战",
          "url": "https://class.imooc.com/sale/mobilearchitect",
          "cover": "https://img1.sycdn.imooc.com/5b16426708e6744716000682.jpg",
          "createTime": "2025-11-10 21:15:16",
        },
        {
          "id": "49",
          "sticky": 1,
          "type": "recommend",
          "title": "好课推荐2",
          "subtitle": "移幼端普通工程师到架构师的全方位蜕变",
          "url": "https://class.imooc.com/sale/mobilearchitect",
          "cover": "https://img1.sycdn.imooc.com/a16c7a69090dc6ff17920764.jpg",
          "createTime": "2025-11-10 21:15:16",
        },
        {
          "id": "39",
          "sticky": 1,
          "type": "video",
          "title": "好课推荐3",
          "subtitle": "五大商业级综合项目实战+鸿蒙高级认证",
          "url": "https://class.imooc.com/sale/mobilearchitect",
          "cover": "https://img1.sycdn.imooc.com/5ac82a690912b72817920764.jpg",
          "createTime": "2025-11-10 21:15:16",
        },
        {
          "id": "29",
          "sticky": 1,
          "type": "recommend",
          "title": "好课推荐4",
          "subtitle": "鸿蒙原生开发工程师",
          "url": "https://class.imooc.com/sale/mobilearchitect",
          "cover": "https://img1.sycdn.imooc.com/a2d38d690803151816000682.jpg",
          "createTime": "2025-11-10 21:15:16",
        },
        {
          "id": "19",
          "sticky": 1,
          "type": "recommend",
          "title": "好课推荐5",
          "subtitle": "Java+大数据+AI架构师实战营",
          "url": "https://class.imooc.com/sale/mobilearchitect",
          "cover": "https://img1.sycdn.imooc.com/398e9469080423e816000682.jpg",
          "createTime": "2025-11-10 21:15:16",
        },
      ],
      "categoryList": [
        {"name": "推荐", "count": 10},
        {"name": "首页", "count": 21},
        {"name": "科技", "count": 20},
        {"name": "新闻", "count": 16},
        {"name": "数码", "count": 12},
        {"name": "小说", "count": 14},
      ],
    };

    return HomeMo.fromJson(result["data"]);
  }
}
